<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="jquery-2.0.0.min.js"></script>
    <script>
        $(function(){
            $("#btn").click(function(){
                if(/^[\u4e00-\u9fa5]{2,6}$/.test($("#txt").val())){
                $("#txt").css("backgroundColor","green")
                }else{
                    $("#txt").css("backgroundColor","red")
                }
            })
        })
    
    </script>
</head>
<body>
    请输入名字：<input type="text" id="txt">
    <input type="button" value="按钮" id="btn">
</body>
</html>